Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add basic glob support to Watcher module #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ashmaroli
Copy link
Member

If users list a glob pattern in the exclude config, expand the pattern and exclude the resulting set of paths.

Currently limited to glob patterns involving just *

Resolves #90
Closes #91
Closes #92

/cc @mohkale

@mohkale
Copy link

mohkale commented Jan 3, 2020

I'd like support for ** as well, is there any plan to add that before merging?

@ashmaroli
Copy link
Member Author

When I said limited to glob patterns involving just *, I meant foo/**/* and foo/*..
See test for reference..

@mohkale
Copy link

mohkale commented Jan 3, 2020

okay, great 😄.

@mohkale
Copy link

mohkale commented Jan 4, 2020

I just tried switching to this branch and I'm still having issues with emacs lock files causing the entire site to be rebuilt. That was the original problem I wanted to get addressed.

Whenever I edit a file, emacs creates a lock file in the same directory with a similair format. I.E. if I start editing src/foo/bar.md emacs makes a src/foo/.#bar.md file. I've added this **/.#* pattern to my exclude section so that the jekyll doesn't place these files in the output directory, but jekyll-watch didn't respect exclude so the entire site was rebuilt anyways (when using jekyll serve).

@ashmaroli
Copy link
Member Author

ashmaroli commented Jan 4, 2020

I've added this **/.#* pattern to my exclude section so that the jekyll doesn't place these files in the output directory

@mohkale That is not the correct glob pattern for the given filename. The correct pattern would be **/*.#*.* or **/.#*.*

exclude:
  - "**/*.#*.*"  # matches src/foo/lorem.#bar.md
  - "**/.#*.*"   # matches src/foo/.#bar.md

@mohkale
Copy link

mohkale commented Jan 4, 2020

but... File.fnmatch("**/.#*", "src/foo/.#bar.md") evaluates to true. Besides I'm quite sure the issue here isn't with my patterns, jekyll isn't outputting any emacs temp files to my build directory anyways.

To clarify.

"**/.#.*" # matches src/foo/lorem.#bar.md

I don't need to account for such files, but thank you anyway.

"**/.#." # matches src/foo/.#bar.md

The only difference between this pattern and the one in my config is that this one demands the file has an extension. I can't switch to this one because I've also got some shell scripts on my site for which I've ommited the extension and simply used a shebang line.

# new pattern
File.fnmatch?("**/.#*.*", "src/foo/.#bar.md") #=> true
File.fnmatch?("**/.#*.*", "src/foo/.#bar") #=> false

# old pattern
File.fnmatch?("**/.#*", "src/foo/.#bar.md") #=> true
File.fnmatch?("**/.#*", "src/foo/.#bar") #=> true

That said, I've added the two patterns you've shared to my config and I've still got the same issue using your branch. Here is the log output

Configuration file: mohkale.io/_config.yml
            Source: ./src
       Destination: ./bin
 Incremental build: disabled. Enable with --incremental
      Generating...
         AutoPages: Generating pages for tags & categories
        Pagination: Complete, processed 9 pagination page(s)
       Jekyll Feed: Generating feed for posts
                    done in 12.622 seconds.
 Auto-regeneration: enabled for './src'
    Server address: http://127.0.0.1:4567
  Server running... press ctrl-c to stop.
# here I started editing FAQ.md, leading to the creation of .#FAQ.md
      Regenerating: 1 file(s) changed at 2020-01-04 17:35:57
                    .#FAQ.md
         AutoPages: Generating pages for tags & categories
        Pagination: Complete, processed 9 pagination page(s)
       Jekyll Feed: Generating feed for posts
                    ...done in 2.4888566 seconds.

to reiterate, my build directory does not contain a .#FAQ.md file, but jekyll still decides to rebuild the entire site when emacs made it, even though the file should've been excluded.

@ashmaroli
Copy link
Member Author

Thank you for the clarifications. I stand corrected..

I also see the problem with my implementation — it can only ignore existing paths that match the wildcard pattern. A new path matching the pattern will pass through undetected.. ☹️

This needs more work

@mohkale
Copy link

mohkale commented Jan 4, 2020

well I look forward to the imminent fix. in the mean time I'll just keep using my own fork. 😄.

@DirtyF DirtyF changed the title Add basic glob support to Watcher module WIP: Add basic glob support to Watcher module Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ignore doesn't accept wildcards?
3 participants